package com.Bigbluebook.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.Bigbluebook.R;

import java.util.List;

public class MyStarAdapter extends RecyclerView.Adapter<MyStarAdapter.ViewHolder> {

    private final List<String> starList; // 假设你有一个存储收藏项的列表

    public MyStarAdapter(List<String> starList) {
        this.starList = starList;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.like_item, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        String star = starList.get(position);
        holder.authorTextView.setText("zhangsan2");
        holder.contentTextView.setText(star);
        holder.timeTextView.setText("2024-10-10");
        // 假设你有一个方法来获取图片资源，这里只是一个示例
        holder.imageView.setImageResource(R.mipmap.ic_launcher);
    }

    @Override
    public int getItemCount() {
        return starList.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        public ImageView imageView;
        public TextView authorTextView;
        public TextView contentTextView;
        public TextView timeTextView;

        public ViewHolder(View view) {
            super(view);

            authorTextView = view.findViewById(R.id.starAuthor);
            contentTextView = view.findViewById(R.id.starContent);
            timeTextView = view.findViewById(R.id.createStarTime);
        }
    }
}
